// 页面路径：store/index.js 
import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from "vuex-persistedstate"

import cart from './modules/cart.js'
import actions from "./actions.js"
import getters from "./getters.js"
import mutations from "./mutations.js"
Vue.use(Vuex); //vue的插件机制

//Vuex.Store 构造器选项
const store = new Vuex.Store({
	state: { //存放状态
		"userInfo": {},
		"token": '',
		statusBarHeight: 0
	},
	modules: {
		cart
	},
	mutations,
	actions,
	getters,
	plugins: [
		persistedState({
			key: "uni_app_storage",
			storage: {
				getItem: key => uni.getStorageSync(key),
				setItem: (key, value) => uni.setStorageSync(key, value),
				removeItem: key => uni.removeStorageSync(key)
			}
		})
	],
})
export default store